/*
 * Created on Jun 8, 2004
 * by Mihai Postelnicu
 * email mihai@code.ro
 *
 *
 */
package ro.gateway.aida.search;

import java.util.Iterator;

import jxl.write.WritableSheet;
import jxl.write.WriteException;
import jxl.write.biff.RowsExceededException;

/**
 * @author Mihai Postelnicu email mihai@code.ro
 */
public class TupleCell extends ResultListCell {

	public TupleCell(String type) {
		super(type);
		list = false;
		xlsExpand=true;
	}

	public String toString() {
		if (items.size() == 0)
			return super.toString();
		ResultCell rc = (ResultCell) items.get(0);
		if (rc.toString().equals(super.toString()))
			return super.toString();
		if (items.size() < 2)
			return rc.toString();

		String ret = rc + " (";
		Iterator i = items.iterator();
		i.next();
		while (i.hasNext()) {
			rc = (ResultCell) i.next();
			ret += rc;
			if (i.hasNext())
				ret += ",";
		}
		return ret + ")";
	}

	public int appendXlsCells(WritableSheet sheet, int x, int y, boolean header)
			throws RowsExceededException, WriteException {
		return super.appendXlsCells(sheet, x, y, header);
	}

}